package com.gengine.resource.info
{
	import flash.display.*;
	import flash.geom.*;
	import flash.system.*;
	
	public class SWFInfo extends ResourceInfo
	{
		private var _clip:MovieClip;
		private var _bitmapData:BitmapData;
		private var _loaderInfo:LoaderInfo;
		private var _appDomain:ApplicationDomain;
		
		public function SWFInfo(param1:Object)
		{
			super(param1);
			
		}
		
		public function get clip() : MovieClip
		{
			return this._clip;
		}
		
		public function get bitmapData() : BitmapData
		{
			var _loc_1:Rectangle = null;
			if (this._bitmapData == null && this._clip)
			{
				this._clip.gotoAndStop(1);
				_loc_1 = this._clip.getBounds(this._clip);
				if (_loc_1.height == 0 || _loc_1.width == 0)
				{
				}
				else
				{
					this._bitmapData = new BitmapData(_loc_1.width, _loc_1.height, true, 0);
					this._bitmapData.draw(this._clip, new Matrix(1, 0, 0, 1, -_loc_1.x, -_loc_1.y), null, null, null, false);
					this._clip = null;
				}
			}
			return this._bitmapData;
		}
		
		override public function set data(param1:Object) : void
		{
			super.data = param1;
			if (param1 is MovieClip)
			{
				this._clip = param1 as MovieClip;
			}
			else if (param1 is LoaderInfo)
			{
				this._loaderInfo = param1 as LoaderInfo;
				this._appDomain = this._loaderInfo.applicationDomain;
				if (this._loaderInfo.swfVersion >= 9)
				{
					this._clip = this._loaderInfo.content as MovieClip;
				}
				else
				{
					throw new Error(this._loaderInfo.url + "版本：" + this._loaderInfo.swfVersion);
				}
			}
			if (this._clip)
			{
				this._clip.gotoAndStop(1);
			}
			
		}
		
		public function getAssetClass(param1:String) : Class
		{
			if (this._appDomain == null)
			{
				throw new Error("not initialized");
			}
			if (this._appDomain.hasDefinition(param1))
			{
				return this._appDomain.getDefinition(param1) as Class;
			}
			return null;
		}
		
		override public function dispose() : void
		{
			isLoaded = false;
			isLoading = false;
			this._clip = null;
			this._loaderInfo = null;
			this._appDomain = null;
			if (this._bitmapData)
			{
				this._bitmapData.dispose();
				this._bitmapData = null;
			}
			super.dispose();
			
		}
		
		override protected function unload(param1:LoaderInfo) : void
		{
			param1.loader.unloadAndStop();
			super.unload(param1);
			
		}
		
	}
}
